<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>企业浏览</title>
<link type="text/css" href="../../css/shCompany.css" rel="stylesheet" >
<link type="text/css" href="../../js/jDialog/jDialog.css" rel="stylesheet" >
<script type="text/javascript" src="../../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../js/jDialog/jquery.dialog.js"></script>
</head>
<script type="text/javascript" >
var sumPage=1;//总页数
var nowPage=1;//当前页数
var nowCount=1;//一页显示的条数
var sumCount=0;//总条数
var nowMin=1;//当前显示第一排的序号
var nowMax=1;//当前显示最后第一排的序号
var userObj =window.userObj;
var userId = userObj[0].userId;
var JobObj=null;
var JobObjString = null;
var i;
$(document).ready(function() {
	$.getResults();
});
$.getResults = function(){
	sumCount=0;
	nowMax=0;
	nowPage=1
	var seaInfo = $("#seTex").val();
	if(seaInfo=="搜索")
		seaInfo="";
	$("#tableInfo tr:gt(0)").remove();
	$.ajax({
		type : 'post',
		dataType : 'text',
		async: false,
		url : '../../company/getJobList.action',
		data:{
			"userDTO.userId":userId,
			"dataDTO.searchKey":seaInfo
		},
		success : function(msg) {
			JobObjString=msg;
			if(JobObjString.length<=2){
				sumCount=0;
			}else{
				JobObj = JSON.parse(msg);
				sumCount = JobObj.length;
			}
		}
	});
	if(sumCount==0){
		$("#tableInfo").append("<tr><td colspan='4'>没有数据</td></tr>");
		$.InitValue(0,0);
		
	}else{
		for(i=0;i<nowCount;i++)
				$.appendTip(i);
		nowMin=1;
		nowMax=i;
		if(sumCount%nowCount==0)
			sumPage=sumCount/nowCount;
		else
			sumPage=Math.floor(sumCount/nowCount)+1;//根据记录数和每页显示条数获取总页数
	}
	$("#sumCount").html(sumCount);
	$.InitValue(1,nowMax);
	$.checkPagesnum();
}
$.appendTip = function(j){
	$("#tableInfo").append("<tr><td>"+(j+1)+"</td><td onclick='$.getRecumInfo(this)' id="+JobObj[j].recruitmentId+" style='cursor:pointer'>"+JobObj[j].recruitmentPosition+"</td><td onclick='$.getComInfo(this)' id="+JobObj[j].companyId+" style='cursor:pointer'>"+JobObj[j].companyName+"</td><td>"+JobObj[j].recruitmentNum+"</td><td><input type='button' value='投  递' class='opbun' style='background-color:#7AC5CD;' onclick='$.deliverResum("+JobObj[j].recruitmentId+")'/></td></tr>");
}

$.getComInfo = function(th){
	var i=th.id;
	var dialog = jDialog.iframe('companysInfo.html?companyId='+i,{
		title : "公司信息",
		width : 500,
		height : 500,
	});
}
$.getRecumInfo = function(th){
	var i=th.id;
	var dialog = jDialog.iframe('recruitmentInfo.html?recruitmentId='+i,{
		title : "职位信息",
		width : 500,
		height : 500,
	});
}
$.deliverResum = function(Id){
	var recruitmentId=Id;
	var dialog = jDialog.confirm('确定投递？',{
		handler : function(button,dialog) {
			$.ajax({
				type : 'post',
				dataType : 'text',
				data:{
					"deliverDTO.recruitmentId":recruitmentId,
					"userDTO.userId":userId
				},
				url : '../../deliver/adDeliver.action',
				success : function(msg) {
					if(msg<=0)
						alert("投递失败");
					else{
					    alert("投递成功");	
					    parent.location.reload();
					}
				}
			});
			dialog.close();
		}
	},{
		handler : function(button,dialog) {
			dialog.close();
		}
	});
}
</script>
<script type="text/javascript" src="../../js/showInfolist.js"></script>
<body>
<div class="mineInfo">
<span id="info1">招聘信息&nbsp;REQUIREMENT</span>
<hr style="height:1px;border:none;border-top:1px solid #555555;" />
</div>
<div id="seleDiv">
<span>一页显示</span><select onchange="$.changCount(this)"><option selected="selected">1</option><option>2</option><option>3</option><option>4</option><option>5</option></select><span>条记录</span>
<input type="text" id="seTex" name="seTex" style="margin-left:40%;width:80px;height:15px;" value="搜索" onblur="if(this.value=='') this.value='搜索';"onfocus="if(this.value=='搜索') this.value='';">
<img src="../../images/search.gif" title="搜索" onclick="$.getResults()"/>
</div>
<table id="tableInfo" order="1" rules="rows">
<tr>
<th width="22%">序号</th>
<th width="22%">招聘职位</th>
<th width="22%">招聘企业</th>
<th width="22%">招聘人数</th>
<th width="24%">投递简历</th>
</tr>
</table>
<div id="pageButton">
<a>当前显示<span id="firtLine">0</span><span>到</span><span id="lastLine">0</span><span>条,共</span><span id="sumCount">2</span><span>条记录</span></a>
<a>第<span style="font-weight:bold;" id="nopage">1</span>/<span style="font-weight:bold;" id="alpage">1</span>页</a>
<span id="cpage"><a onclick="$.firstPage()" id="fipage">首页</a>
<a onclick="$.formPage()" id="fopage">上一页</a>
<a onclick="$.nextPage()" id="nepage">下一页</a>
<a onclick="$.lastPage()" id="lapage">尾页</a></span>
</div>
</body>
</html>